package com.qixin.api.serviceimpl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.qixin.api.bean.*;
import com.qixin.api.mapper.ComMoneyInfoMapper;
import com.qixin.api.service.ComMoneyInfoService;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 资金明细表 服务实现类
 * </p>
 *
 * @author 吕正睿
 * @since 2018-11-15
 */
@Service
public class ComMoneyInfoServiceImpl extends ServiceImpl<ComMoneyInfoMapper, ComMoneyInfo> implements ComMoneyInfoService {

	@Override
	public ResultPage<ComMoneyInfo> selectMyPage(VoPage voPage, HttpSession session, ComMoneyInfo comMoneyInfo) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("page", (voPage.getPage() - 1)*voPage.getLimit());
		paramMap.put("limit", voPage.getLimit());
		paramMap.put("ptId",((ComPtUser)session.getAttribute("user")).getId());
		List<ComMoneyInfo> list = baseMapper.selectMyPage(paramMap,comMoneyInfo);
		Integer count = baseMapper.countMyPage(paramMap,comMoneyInfo);
		ResultPage<ComMoneyInfo>resultPage=new ResultPage<>();
		resultPage.setCode(0);
		resultPage.setCount(count);
		resultPage.setData(list);
		resultPage.setMsg("成功");

		return resultPage;

	}
	@Override
	public ResultPage<ComMoneyInfo> selectMyPageAll(VoPage voPage, ComMoneyInfo comMoneyInfo) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("page", (voPage.getPage() - 1)*voPage.getLimit());
		paramMap.put("limit", voPage.getLimit());
		List<ComMoneyInfo> list = baseMapper.selectMyPageAll(paramMap,comMoneyInfo);
		Integer count = baseMapper.countMyPage1(paramMap,comMoneyInfo);
		ResultPage<ComMoneyInfo>resultPage=new ResultPage<>();
		resultPage.setCode(0);
		 resultPage.setCount(count);
		resultPage.setMsg("成功");
		resultPage.setData(list);
		return resultPage;
	}
	@Override
	public ResultPage<ComMoneyInfo> query(Map map,VoPage voPage){
		Map<String,Object> paramMap=new HashMap<>();
		paramMap.put("page",(voPage.getPage()-1)*voPage.getLimit());
		paramMap.put("limit",voPage.getLimit());
		List<ComMoneyInfo>list=baseMapper.query(map,paramMap);
		Integer count=baseMapper.countMyPageq(paramMap);
		ResultPage<ComMoneyInfo>resultPage=new ResultPage<>();
		resultPage.setCode(0);
		resultPage.setCount(count);
		resultPage.setMsg("成功");
		resultPage.setData(list);
		return  resultPage;
	}
}
